package com.xnfh.login.viewmodel

import com.xnfh.framework.base.BaseViewModel
import com.xnfh.framework.bean.RespStateData
import com.xnfh.common.bean.UserInforBean
import org.json.JSONObject

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/11/9 19:23
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/11/9 19:23
 * @UpdateRemark: 更新说明
 */
class LoginModel : BaseViewModel() {
    private val loginRes = LoginRes()
    var loginResData = RespStateData<String>()
    var loginInforResData = RespStateData<UserInforBean>()
    fun requestLogin(username: String, password: String) = launch {
        val jsonMes = JSONObject()
        jsonMes.put("suAccount", username)
        jsonMes.put("password", password)
        val requestBody = creatRequestBody(jsonMes.toString())
        loginRes.requestLogin(requestBody, loginResData)
    }

    fun requestUserInfor() = launch {
        loginRes.requestUserInfor(loginInforResData)
    }
}